use actix::prelude::*;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
#[derive(Message)]
#[rtype(result = "()")]
pub struct Message(pub String, pub bool); //string:消息，bool是否正常连接（否则断开）
#[derive(Message)]
#[rtype(result = "()")]
pub struct SessionStop();

#[derive(Message)]
#[rtype(result = "()")]
pub struct Connection {
    pub id: usize,
    pub info: HashMap<String, String>,
    pub addr: Recipient<Message>,
}

#[derive(Message)]
#[rtype(result = "()")]
pub struct Disconnect {
    pub id: usize,
}

#[derive(Message)]
#[rtype(result = "()")]
pub struct ClientMessage {
    pub id: usize,
    pub msg: String,
}

#[derive(Message)]
#[rtype(result = "()")]
pub struct WsRequest {
    pub id: usize,
    pub text: String,
}

pub struct WsResponse {
    pub id: usize,
    pub text: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct PostBean {
    pub mold: String,      //类型
    pub id: usize,         //发送的id
    pub value_mold: usize, //值类型
    pub value: String,     //值
    #[serde(default)]
    pub json: Value,
}
